<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>03-判断是否为数组</title>
</head>
<body>
    <script>
        // 翻转数组
        let arr = ['red', 'pink', 'yellow','skyblue'];
        let arr1 = [];
        function newArr(arr){
            if(arr instanceof Array){

            }else{
                console.log('当前参数，不合法');
                return;
            }
            
             for(let i = arr.length-1; i>=0;i--){
                arr1[arr1.length] = arr[i];
            }
            return arr1;
        }
        newArr(arr);  // 合法的
        // newArr('苹果');  //  当前参数不合法
        console.log(arr1);

        // 1. 判断当前对象是否为某个实例
        let d = new Date();
        console.log(arr instanceof Array);  //true
        console.log(d instanceof Date);   // ture
        console.log(arr instanceof Date);  // false

        // 2. 判断是否为数组
        console.log(Array.isArray(arr)); // true
        console.log(Array.isArray(d));  //false
    </script>
</body>
</html>